package ooday03;

import com.sun.org.apache.bcel.internal.generic.D2F;

/*1. 设计Animal类、Swim接口、Dog类、Fish类、Chick类，完成继承和实现关系，创建数组并测试
 */
//设计捕食系统,高等级动物可以捕食低等级动物
//设计繁殖系统,在适龄范围内的雌性动物,可生产性别随机的0岁孩子
public class Test {
    public static void main(String[] args) {
        Tiger t1 = new Tiger("武松", 5, "棕色", "female");
        Tiger t2 = new Tiger("张飞", 2, "黑色", "female");
        Dog d1 = new Dog("李白", 3, "白色", "male");
        System.out.println(t1.toString());
        System.out.println(d1.toString());
        Tiger t3 = t1.giveBirthTo();
        Tiger t4 = t2.giveBirthTo();
        System.out.println("----------------------------");

        Fish[] fish = new Fish[4];
        fish[0] = new Fish("小金", 1, "金", "male");
        fish[1] = new Fish("大金", 3, "白", "female");
        fish[2] = new Fish("小绿", 1, "绿", "male");
        fish[3] = new Fish("大绿", 2, "白", "female");
        for (int i = 0; i < fish.length; i++) { //遍历fish数组
            fish[i].eat();
            System.out.println(fish[i].giveBirthTo());
        }
        System.out.println("----------------------------");

        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑", 2, "黑", "male");
        dogs[1] = new Dog("小白", 1, "白", "female");
        dogs[2] = new Dog("小灰", 3, "灰", "male");
        System.out.println(dogs[0].getName());
        dogs[1].setAge(4);  //修改第2个狗狗的年龄为4岁
        dogs[2].swim(); //第3只狗狗在游泳
        dogs[0].hunt(fish[0]);//狩猎鱼
        dogs[1].hunt(t1);//狩猎老虎
        for (int i = 0; i < dogs.length; i++) { //遍历dogs数组
            System.out.println(dogs[i].getName()); //输出每只狗狗的名字
            dogs[i].eat(); //每只狗狗吃饭
        }
        System.out.println("----------------------------");

        Tiger[] tigers = new Tiger[2];
        tigers[0] = new Tiger("小花", 1, "花", "male");
        tigers[1] = new Tiger("大花", 3, "白", "female");
        tigers[0].hunt(d1);
        tigers[1].hunt(dogs[1]);
        for (int i = 0; i < tigers.length; i++) { //遍历chickes数组
            System.out.println(tigers[i].getName());
            tigers[i].eat();
        }
    }
}
